package xiancheng;



public class Text {
    public static void main(String[] args) {

    }

    /*public static void main(String[] args) {
        Thread t = new Thread(() -> {
            try {
                System.out.println("a");
                Thread.sleep(1000);//sleep方法是Thread的静态方法，它只作用于当前线程（它知道当前线程是哪个)
                System.out.println("b");//调用sleep后，线程会直接进入到等待状态，直到时间结束
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t.start();
    }*/
   /* private static int value = 0;
    public static void main(String[]args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) value++;
            System.out.println("线程1完成");
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) value++;
            System.out.println("线程2完成");
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);//主线程停止1秒，保证两个线程执行完成
        System.out.println(value);
    }*/
    /*public static void main(String[] args)throws InterruptedException {
        Thread t = new Thread(() -> {
            Thread me = Thread.currentThread();//获取当前线程对象
            for (int i = 0; i < 50; i++) {
                System.out.println("打印:" + i);
                if (i == 20) me.stop();//此方法会直接终止此线程
            }
        });
        t.start();
    }*/
   /* public static void main(String[] args) throws InterruptedException {
        System.out.println("a");
        Thread.sleep(1000);
        System.out.println("a");
        Thread.sleep(1000);
        System.out.println("a");
    }*/
    /*public static void main(String[] args) {
        Thread t = new Thread(() ->{
            System.out.println("创建多线程");
        });
        t.start();
    }*/
    /*public static void main(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("创建多线程");
            }
        });
        t.start();
    }*/
    /*public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 500; i++) {
                System.out.println("我是一号线程: " + i);
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 500; i++) {
                System.out.println("我是二号线程:" + i);
            }
        });
        t1.run();
        t2.start();
    }*/
}
